<template>
	<view class="page-content">
		<!-- 打卡管理 -->
		<view class="page-top">
			<view class="tit"><text class="txt">进行中</text>{{datalist.title}}</view>
		</view>
		<!--队伍信息-->
		<view class="body-box">
			<view class="box-tit2">
				<view class="box-tit-l">
					<view class="icon-tb icons icon-duoren"></view>
					<text class="txt-jc">团队名称：{{datalist.team_name}}（{{datalist.user_count}}人）</text>
					<text class="txt-zb">{{datalist.gg_title}}</text>
				</view>
			</view>
			<!--队长+队员-->
			<view class="box-team2">
				<block v-for="(item,index) in datalist.user" :key="index">
					<view class="box-team-li">
						<view class="box-team-l">
							<image class="icon-tb icon-duiyuan" :class="item.type===1?'icon-dz':'icon-dy'"
								:src="item.type===1?duizhang:duiyuan" />
							<text>{{item.type===1?'队长：':'队员：'}}</text>
							<text class="box-team-l-name">{{item.name}}</text>
							<text class="box-team-l-size">服装：{{item.size}}</text>
						</view>
					</view>
				</block>
			</view>
		</view>
		<!-- 打卡管理 -->
		<view class="page-tit">
			<image class="icon-tit" src="/static/clockIn/icon-tit.png"></image>
			检录状态：
			<view class="txt-tit" :style="{color:datalist.sign_status===2?'#999999':'#02BB6F'}">
				{{datalist.sign_status===2?'未检录':'已检录'}}<text class="txt-tit-time"
					v-if="datalist.sign_status===1">{{datalist.time}}</text></view>
		</view>
		<view class="page-qd" v-if="datalist.sign_status===2" @click="qiandao">
			给他检录
		</view>
		<!-- 扫码 -->
		<view class="page-sm" @click="saoma">
			扫码
		</view>
<view class="example-body" v-show="isloadding==='loading'">
				<uni-load-more iconType="snow" :status="isloadding" />
			</view>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapState
	} from 'vuex'
	//接口
	import {
		getScanInfos, //扫码后获得的数据
		ScanSigns //检录
	} from '@/common/api.js'
	import uniLoadMore from "@/components/uni-load-more/uni-load-more2.vue"
	export default {
		components: {uniLoadMore},
		data() {
			return {
				isloadding: '',
				duizhang: '/static/clockIn/captain.png',
				duiyuan: '/static/clockIn/icon-dy.png',
				code: '',
				datalist: {
					title: '',
					team_name: '',
					gg_title: '',
					sign_status: '',
					time: '',
					user: [],
					coord_data: [],
					user_count: ''
				},

			}
		},
		onLoad(option) {
			console.log(2, option)
			if (option.code) {
				this.code = option.code;
			}
			this.getdata();
		},
		methods: {
			qiandao() {
				ScanSigns({
					code: this.code
				}).then(res => {
					console.log(22, res)
					if (res.code === 2000) {
						uni.showToast({
							title: '检录成功',
							icon: 'none',
							duration: 2000
						})
						this.getdata();
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			saoma() {
				let _self = this;
				// 只允许通过相机扫码
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						_self.isloadding = 'loading';
						getScanInfos({
							code: res.result
						}).then(res2 => {
							_self.isloadding = 'load';
							if (res2.code === 2000) {
								if(res2.data.type === 'clock'){
									uni.navigateTo({
										url: `/packageA/ewm/clock?code=${res2.data.code}`
									})
								}else if(res2.data.type === 'sign'){
									uni.navigateTo({
										url: `/packageA/ewm/sign?code=${res2.data.code}`
									})
								}else if(res2.data.type === 'equip'){
									uni.navigateTo({
										url: `/packageA/ewm/draw?code=${res2.data.code}`
									})
								}
							} else {
								uni.showToast({
									title: res2.msg,
									duration: 2000,
									icon: 'none'
								})
							}
						})
					}
				});
			},
			getdata() {
				getScanInfos({
					code: this.code
				}).then(res => {
					if (res.code === 2000) {
						this.datalist.title = res.data.other_data.title;
						this.datalist.team_name = res.data.other_data.team_name;
						this.datalist.gg_title = res.data.other_data.gg_title;
						this.datalist.sign_status = res.data.other_data.sign_data.sign_status;
						this.datalist.time = res.data.other_data.sign_data.time;
						this.datalist.user = res.data.other_data.user;
						this.datalist.coord_data = res.data.other_data.coord_data;
						this.datalist.user_count = res.data.other_data.user.length;
					}
				})
			},

		}
	}
</script>

<style lang="scss">
	.example-body{
		position: fixed;
		z-index: 999;
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 0 auto;
		left: calc(50% - 150rpx);
		top: calc(50% - 150rpx);
		width: 300rpx;
		height: 300rpx;
		background: rgba(0,0,0,0);
	}
	.page-qd {
		font-size: 32rpx;
		line-height: 86rpx;
		color: #fff;
		text-align: center;
		margin: 30rpx;
		height: 86rpx;
		background: #02BB6F;
		box-shadow: 0px 7px 7px rgba(2, 187, 111, 0.1);
		border-radius: 43rpx;
	}

	.page-sm {
		font-size: 32rpx;
		line-height: 86rpx;
		color: #fff;
		text-align: center;
		margin: 0 30rpx 30rpx 30rpx;
		height: 86rpx;
		background: #02BB6F;
		box-shadow: 0px 7px 7px rgba(2, 187, 111, 0.1);
		border-radius: 43rpx;
	}

	.page-tit {
		display: flex;
		align-items: center;
		margin: 32rpx;
		font-size: 32rpx;
		font-weight: 600;
		line-height: 56rpx;
		color: #333333;

		.txt-tit {
			font-size: 32rpx;
			font-weight: 400;
			line-height: 56rpx;

			.txt-tit-time {
				padding-left: 14rpx;
			}
		}

		.icon-tit {
			width: 35rpx;
			height: 42rpx;
			margin-right: 20rpx;
		}
	}

	.icon-tb {
		margin-right: 10rpx;
	}

	.icon-dz {
		width: 34rpx;
		height: 26rpx;
		margin-right: 18rpx;
	}

	.icon-dy {
		width: 32rpx;
		height: 32rpx;
		margin-right: 19rpx;
	}

	.page-top {
		display: flex;
		align-items: center;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 56rpx;
		color: #333333;
		padding: 20rpx 30rpx;

		.txt {
			background: rgba(2, 187, 111, 0.1);
			border-radius: 4rpx;
			font-size: 32rpx;
			font-weight: 600;
			line-height: 54rpx;
			color: #02BB6F;
			margin-right: 18rpx;
			padding: 0 15rpx;
		}
	}

	.page-content {
		width: 100vw;
		display: flex;
		flex-direction: column;
		background: #fff;
	}

	.body-box {
		background: #F9F9F9;
		border-radius: 16rpx;
		display: flex;
		flex-direction: column;
		margin: 0rpx 30rpx;
		padding: 20rpx 30rpx;

		.record_count {
			display: flex;
			align-items: center;
			width: 100%;
			margin-bottom: 20rpx;

			.record_l {
				width: 70rpx;
				height: 70rpx;
				border-radius: 35rpx;
				line-height: 70rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				text-align: center;
				margin-right: 30rpx;
			}

			.record_r {
				display: flex;
				flex-direction: column;
				width: calc(100% - 100rpx);
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				padding-bottom: 10rpx;
				border-bottom: 1rpx solid #E8E8E8;

				.record_r_o {
					display: flex;
					margin-bottom: 20rpx;
					line-height: 42rpx;

				}

				.record_r_t {
					display: flex;

					.comp_content_sta {
						display: flex;
						align-items: center;

						.record_r_txt {
							font-size: 28rpx;
							font-weight: 400;
							line-height: 42rpx;
							color: #666666;
						}

						.record_r_but {
							background: #02BB6F;
							border-radius: 6rpx;
							height: 50rpx;
							color: #fff;
							font-size: 22rpx;
							font-weight: 300;
							line-height: 50rpx;
							padding: 0 20rpx;
							margin-left: 20rpx;
						}

						.record_r_date {
							margin-left: 20rpx;
							color: #02BB6F;
							font-size: 28rpx;
							font-weight: 400;
							line-height: 42rpx;
						}
					}
				}

				.record_r_t {
					margin-bottom: 20rpx;
				}

				.record_r_th {
					display: flex;
					margin-bottom: 20rpx;

					.record_r_th_img {
						width: 160rpx;
						height: 160rpx;
					}
				}
			}
		}

		.box-team2 {
			display: flex;
			flex-direction: column;

			.box-team-li {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				margin-bottom: 30rpx;

				.box-team-l {
					display: flex;
					align-items: center;

					.box-team-l-name {
						margin-right: 60rpx;
					}
				}

			}
		}

		.box-team2.box-team-li:nth-of-type(2) .box-team-l.icon-duiyuan {
			display: none !important;
		}

		.box-tit {
			display: flex;
			align-items: center;
			font-size: 28rpx;
			font-weight: 500;
			color: #333333;
			border-bottom: 1rpx solid #f9f9f9;
			padding-bottom: 15rpx;
			margin-bottom: 15rpx;

			.tit-text {
				color: #FE5050;
			}

			.txt-jc {
				font-weight: bold;
			}

			.comp_content_sta {
				border-radius: 15rpx;
				height: 30rpx;
				line-height: 30rpx;
				font-size: 18rpx;
				padding: 0 10rpx;
				margin-left: 20rpx;
			}
		}

		.box-tit2 {
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 28rpx;
			font-weight: 500;
			color: #333333;
			border-bottom: 1rpx solid #f9f9f9;
			padding-bottom: 15rpx;
			margin-bottom: 15rpx;

			.box-tit-l {
				display: flex;
				align-items: center;

				.tit-text {
					color: #FE5050;
				}

				.txt-jc {
					font-weight: bold;
					margin-right: 20rpx;
				}

				.txt-zb {
					background: rgba(2, 187, 111, 0.1);
					border-radius: 8rpx;
					font-size: 18rpx;
					font-weight: 400;
					line-height: 40rpx;
					height: 40rpx;
					color: #02BB6F;
					padding: 0 20rpx;
				}

				.comp_content_sta {
					border-radius: 15rpx;
					height: 30rpx;
					line-height: 30rpx;
					font-size: 18rpx;
					padding: 0 10rpx;
					margin-left: 20rpx;
				}
			}
		}
	}
</style>
